'use strict'

function getArray(row){
	var temp = row.replace(/"/g,'').replace('\r',''),
		array = temp.split('|');
	return array;
}


module.exports = {
	dimension: function(row){
		var temp = row.replace(/"/g,'').replace('\r',''),
			array = temp.split('|');

		//if( array.length < 6 ) {
			
		return {
			key: array[4],
			value: array[5]
		}
	},
	record: function(row){
		var array = getArray(row);

		return {
			key: array[0]+'__'+array[1],
			time: array[1],
			dept: array[4],
			patientId: array[0]
		}
	},
	dept: function(entity){
		var depts = Object.keys(entity.depts).sort(function(e1,e2){
			return e1-e2;
		}).join(',');
		
		return {
			key: depts+'__'+entity.time,
			time: entity.time,
			patientId: entity.patientId
		}
	}
};
